import { Application } from 'egg';
import {
    indexRule,
    createRule,
    baseRule,
    updateRule
} from '../validate/wx/collect';

/**
 * 小程序路由
 */
export default (app: Application) => {
    // const { auth } = app.middleware;
    const { } = app;

    return {
        'collect.list': {
            method: 'GET',
            path: '/wx/collect/list',
            options: {
                tags: ['collect/list'],
                description: '收藏订单列表',
                handler: app.controller.wx.collect.list,
                // middlewares: [jwt, auth('collect.list')],
                validate: indexRule,
            },
        },
        'collect.detail': {
            method: 'GET',
            path: '/wx/collect/:id',
            options: {
                tags: ['collect/detail'],
                description: '收藏订单详情',
                handler: app.controller.wx.collect.detail,
                // middlewares: [jwt, auth('collect.detail')],
                validate: baseRule,
            },
        },
        'collect.create': {
            method: 'POST',
            path: '/wx/collect',
            options: {
                tags: ['collect/create'],
                description: '新增收藏订单',
                handler: app.controller.wx.collect.create,
                // middlewares: [jwt, auth('collect.create')],
                validate: createRule,
            },
        },
        'collect.update': {
            method: 'PUT',
            path: '/wx/collect',
            options: {
                tags: ['collect/update'],
                description: '更新收藏订单',
                handler: app.controller.wx.collect.update,
                // middlewares: [jwt, auth('collect.update')],
                validate: updateRule,
            },
        },
        'collect.destroy': {
            method: 'DELETE',
            path: '/wx/collect/:id',
            options: {
                tags: ['wx/collect'],
                description: '删除收藏订单',
                handler: app.controller.wx.collect.destroy,
                // middlewares: [jwt, auth('collect.destroy')],
                validate: baseRule,
            },
        },
    };
};
